import { Role } from "@/types/system/role";
import { User } from "@/types/system/user";
import { get, post, put, remove } from "@/utils/request";

/**
 * 获取角色列表
 * @returns
 */
export const queryRoleList = (data: Role.Query)=>post<Array<Role.Row>>(`/role/list`,data);
/**
 * 删除角色
 * @returns
 */
export const deleteRoleById = (roleId: string) =>remove(`/role/${roleId}`);
/**
 * 修改角色状态
 * @param data
 * @returns
 */
export const changeRoleStatus = (data: Role.StatusVo) =>put(`/role/changeStatus`,data);
/**
 * 修改角色信息
 * @param data
 * @returns
 */
export const updateRole = (data: Role.Form) =>put( `/role/update`,data);
/**
 * 新增角色信息
 * @returns
 */
export const addRole = (data: Role.Form) =>post(`/role/add`,data);
/**
 * 获取角色信息
 * @param data
 * @returns
 */
export const queryRole = (id: string) =>get( `/role/${id}`);
/**
 * 授权菜单
 * @returns
 */
export const setAuthMenu = (data: Role.AuthMenu) => post(`/role/authMenu`,data);
/**
 * 授权用户
 * @param data
 * @returns
 */
export const setAuthUser = (data: Role.AuthUser) => post(`/role/authUser`,data);

/**
 * 获取角色菜单信息
 * @param data
 * @returns
 */
export const queryRoleMenu = (roleId: string) => get( `/role/menu?roleId=${roleId}`);
/**
 * 获取角色菜单信息
 * @param data
 * @returns
 */
export const queryRoleMenuIds = (roleId: string) => get<Role.RoleMenu[]>(`/role/menuIds?roleId=${roleId}`);
/**
 * 获取角色菜单信息
 * @param data
 * @returns
 */
export const queryRoleUser = (data:User.RoleUserQuery) => post<PageVo<User.Row>>( `/role/user`,data);
  /**
   * 排除当前角色的人
   * @param data 
   * @returns 
   */
  export const queryExcludeRoleUser = ( data: User.RoleUserQuery)=> post<PageVo<User.Row>>(`/role/excludeUser`,data);
/**
 * 解绑
 * @param roleId
 * @param data
 * @returns
 */
export const unbindUser = (data: Role.AuthUser) =>remove(`/role/unbindUser`,data);
